package com.wuhao.code.check.model.base

import com.aegis.mybatis.xmlless.annotations.DisableLogic
import com.aegis.mybatis.xmlless.annotations.ExcludeProperties
import com.aegis.mybatis.xmlless.annotations.JsonResult
import com.aegis.mybatis.xmlless.annotations.SelectedProperties
import com.aegis.mybatis.xmlless.model.base.BaseMethodWrapper
import com.intellij.psi.PsiElement
import com.wuhao.code.check.getStringListAnnotationValue
import com.wuhao.code.check.hasAnnotation
import org.apache.ibatis.annotations.ResultMap

/**
 *
 * @author 吴昊
 * @date 2024/1/24 10:37
 * @since v0.0.0
 * @version 1.0
 */
abstract class BasePsiMethodWrapper<T: PsiElement>(protected val fn: T) : BaseMethodWrapper {

  override fun getExcludeProperties(): List<String> {
    return fn.getStringListAnnotationValue(
        ExcludeProperties::class.java.name, "value"
    )
  }

  override fun isJsonResult(): Boolean {
    return this.fn.hasAnnotation(JsonResult::class.java)
  }

  override fun getSelectedProperties(): List<String> {
    return fn.getStringListAnnotationValue(
        SelectedProperties::class.java.name, "value"
    )
  }

  override fun getResultMap(): List<String> {
    return fn.getStringListAnnotationValue(ResultMap::class.java.name, "value")
  }

  override fun isLogicDisabled(): Boolean {
    return fn.hasAnnotation(DisableLogic::class.java)
  }

}
